package cate.game.play.buff.h;

import cate.game.play.base.HpCfg;
import cate.game.play.buff.BuffHandler;
import cate.game.play.buff.BuffParam;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.fighter.HealResult;
import cate.game.play.proce.action.ctx.ActionCtx;
import cate.game.play.proce.action.ctx.TimeActionCtx;
import cate.game.play.proce.move.MoveCtx;

/**
 * 携带该状态的目标出手时转移自身8%当前生命值给发起者,溢出生命转化为【灵能护盾】,每回合至多2次,持续2回合
 */
public class 虹吸果蝇BH extends BuffHandler {

	private HpCfg 血量配置;

	private int 护盾buff;

	private int 回合次数;

	//血量配置=？？&护盾buff=？？&回合次数=2
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		血量配置 = new HpCfg(args);
		护盾buff = args.getInt("护盾buff", 0);
		回合次数 = args.getInt("回合次数", 0);
	}

	@Override
	public void onRoundBegin(ActionCtx action) {
		roundNum = 0;
	}

	private int roundNum;

	@Override
	public void onOwnerMoveDone(MoveCtx move, TimeActionCtx action) {
		if (roundNum >= 回合次数) {
			return;
		}
		double value = 血量配置.settle(buff.caster, buff.owner);
		buff.owner.attr.buffHurt(action, buff.caster, value);
		HealResult healResult = buff.caster.attr.buffHeal(action, buff.caster, value);
		if (healResult.overFlowHeal > 0) {
			BuffParam param = new BuffParam().buffHpSet(healResult.overFlowHeal);
			buff.caster.buff.tryAddByTid(action, buff.caster, 护盾buff, param);
		}
	}
}
